import 'package:flutter_ncsjqz_getx/constant/constant.dart';
import 'package:flutter_ncsjqz_getx/http/dio_service.dart';
import 'package:flutter_ncsjqz_getx/model/msg_count_entity.dart';
import 'package:flutter_ncsjqz_getx/model/my_follow_fans_count_entity.dart';
import 'package:flutter_ncsjqz_getx/model/user_detail_entity.dart';
import 'package:flutter_ncsjqz_getx/model/wallet_detail_entity.dart';
import 'package:package_get/base_logic.dart';

class MyLogic extends BaseLogic {
  UserDetailData? userDetailData = UserDetailData();
  List listCount = [
    0,0,0
  ];
  MsgCountData? msgCountData = MsgCountData();

  getData() async{
    // 获取用户信息
    UserDetailEntity data = await DioService<UserDetailEntity>().queryPersonalDetail();
    // 获取关注数
    MyFollowFansCountEntity myFollowFansCountEntity = await DioService<MyFollowFansCountEntity>().followAndFansCount();
    // 获取总额
    WalletDetailEntity walletDetailEntity = await DioService<WalletDetailEntity>().walletDetail();
    // 获取统计
    MsgCountEntity msgCountEntity = await DioService<MsgCountEntity>().statisticsMsgCount();
    if(msgCountEntity.code == 0) msgCountData = msgCountEntity.data;
    if(walletDetailEntity.code == 0) listCount[0] = walletDetailEntity.data!.totalAmount ?? 0;
    if(myFollowFansCountEntity.data != null){
      listCount[2] = myFollowFansCountEntity.data!.followCount ?? 0;
      listCount[1] = myFollowFansCountEntity.data!.fansCount ?? 0;
    }
    userDetailData = data.data;
    Constant.userDetailData = data.data;
    update();
  }
}
